<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <title></title>
    <script src="../js/jquery.js"></script>
    <script src="../js/common.js"></script>
    <style>
        body {
            background-color: #404040;
        }
    </style>
    <style type="text/css">
        .background {
            display: block;
            width: 100%;
            height: 100%;
            opacity: 0.4;
            filter: alpha(opacity=40);
            background: while;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 2000;
        }

        .progressBar {
            border: solid 2px #86A5AD;
            background: white url(../images/pageloading.gif) no-repeat 10px 10px;
        }

        .progressBar {
            display: block;
            width: 160px;
            height: 28px;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-left: -74px;
            margin-top: -14px;
            padding: 10px 10px 10px 50px;
            text-align: left;
            line-height: 27px;
            font-weight: bold;
            position: absolute;
            z-index: 2001;
        }
    </style>
</head>

<body>
<div id="background" class="background" style="display: none; "></div>
<div id="progressBar" class="progressBar" style="display: none; ">文件解析中，请稍等...</div>
<div id="app">

</div>
</body>

</html>
<script>
    var checkFileUrl = getRootPath() + "/service/checkFile";
    var convertFileUrl = getRootPath() + "/service/convertFile";
    var ajaxbg = $("#background,#progressBar");
    $(function () {
        checkFile();
    })

    function checkFile() {
        var data = {
            file: getQueryString("file"),

        };
        ajaxbg.show();
        JsonAjax(JSON.stringify(data), checkFileUrl, function (result, status) {
            if (result.code == 0) {
                var fileGuid = result.data.fileGuid;
                convertFile(fileGuid);
            } else {
                ajaxbg.hide();
                alert(result.msg);
            }
        })
    }

    function convertFile(fileGuid) {
        var data = {
            fileGuid: fileGuid,
        };
        JsonAjax(JSON.stringify(data), convertFileUrl, function (result, status) {
            ajaxbg.hide();
            if (result.code == 0) {
                var convertInfo = result.data.obj;
                var pageNum = convertInfo.pageNum;
                var convertType = convertInfo.convertType;
                var isConvert = convertInfo.haveConvert ? "1" : "2"
                if (convertType == "doc" || convertType == "ppt" || convertType == "pdf") {
                    window.location.href = getRootPath() + "plaform/basepreview.html?pageNum=" + pageNum + "&fileGuid=" + fileGuid + "&isConvert=" + isConvert;
                } else if (convertType == "excel") {
                    window.location.href = getRootPath() + "plaform/excelpreview.html?pageNum=" + pageNum + "&fileGuid=" + fileGuid + "&isConvert=" + isConvert;
                } else if (convertType == "image") {
                    window.location.href = getRootPath() + "plaform/imagepreview.html?file=" + getQueryString("file");
                }else if (convertType == "vedio") {
                    window.location.href = getRootPath() + "plaform/vediopreview.html?file=" + getQueryString("file");
                }
                else if (convertType == "txt") {
                    window.location.href = getRootPath() + "plaform/txtpreview.html?&fileGuid=" + fileGuid;
                }
            } else {
                alert(result.msg);
            }
        })
    }


</script>